<template>
  <div class="mine">
    <div class="user">
      <img :src="userinfo.avatarUrl" alt="" />
      <div class="suer_name">
        <span class="userid">{{ userinfo.id }}</span>
        <span class="username">{{ userinfo.phone | phoneFilter }}</span>
      </div>
    </div>
    <div class="banner">
      <div class="hongbao">
        <span>红包</span>
        <span>7张今天到期</span>
      </div>
      <div class="yu">
        <span>余额</span>
        <span>0元</span>
      </div>
    </div>
    <!-- 常用工具 -->
    <div class="tool">
      <div class="block">
        <div class="title">常用工具</div>
        <div class="list">
          <div class="btn">
            <van-icon name="location-o" size="24" />
            <span @click="dizhi">我的地址</span>
          </div>
          <div class="btn">
            <van-icon name="phone-circle-o" size="24" />
            <span>我的客服</span>
          </div>
          <div class="btn" @click="toCollect">
            <van-icon name="like-o" size="24" />
            <span>店铺关注</span>
          </div>
          <div class="btn">
            <van-icon name="star-o" size="24" />
            <span>评价有礼</span>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      userinfo: JSON.parse(localStorage.getItem("userinfo")),
    };
  },
  methods: {
    toCollect() {
      this.$router.push("/collect");
    },
    dizhi() {
      this.$router.push("/address");
    },
  },
  filters: {
    // 过滤处理手机号
    phoneFilter(phone) {
      return phone.slice(0, 3) + "****" + phone.slice(-4);
    },
  },
};
</script>

<style lang="scss" scoped>
* {
  margin: 0;
  padding: 0;
}
.main {
  background-color: #f5f5f5;
}
.user {
  margin: 10px;
  height: 80px;
  display: flex;
  align-items: center;
  img {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    margin-right: 10px;
  }
  .suer_name {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    span {
      margin: 5px 5px;
    }
    .userid {
      font-weight: bold;
      font-size: 18px;
    }
    .username {
      font-size: 12px;
      color: #999;
    }
  }
}
.banner {
  height: 80px;
  margin: 5px 10px;
  border-radius: 5px;
  background-color: cornflowerblue;
  display: flex;
  justify-content: space-around;
  .hongbao {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }
  .yu {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    text-align: center;
  }
}
.block {
  margin: 10px;
  padding: 5px;
  border-radius: 5px;
  background-color: #efefef;
  .title {
    font-weight: bold;
    padding-left: 10px;
  }
  .list {
    display: flex;
    justify-content: space-around;
    align-content: center;
    .btn {
      text-align: center;
      display: flex;
      flex-direction: column;
      align-items: center;
      padding: 20px 0;
      i {
        margin-bottom: 10px;
      }
    }
  }
}
</style>